<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title><?=getValInArr(getSess(SESS_DIC),array('webInfo','webtitle'))?></title>
    <meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport"/>
    <meta content="yes" name="apple-mobile-web-app-capable"/>
    <meta content="black" name="apple-mobile-web-app-status-bar-style"/>
    <meta content="telephone=no" name="format-detection"/>
    <script src="<?php echo base_url().'public/home/js/' ?>jquery.js"></script>
    <?php include_once "public/home/html/bootstrap.php"  ?>
    <?php include_once "public/home/html/imgupload.php"  ?>
    <?php include_once "public/home/html/alert.php"  ?>   
    <script type="text/javascript" src="<?php echo base_url().'public/home/js/' ?>function.js"></script>
    <link rel="stylesheet" href="<?php echo base_url().'public/h_ui/lib/Hui-iconfont/1.0.8/' ?>iconfont.css">
    <link rel="stylesheet" href="<?php echo base_url().'public/home/css/' ?>mui.min.css">
    <?php include_once "public/home/html/alert.php"  ?>   
    <script type="text/javascript" src="<?php echo base_url().'public/home/js/' ?>function.js"></script>
    <link rel="stylesheet" href="<?php echo base_url().'public/assets/css/' ?>font-awesome.min.css">
</head>
<body>
    <style>
        html{
          overflow:scroll!important;
        }
        body{
            padding: 3%;
            text-align: center;
            background-color: #ffffff;
        }
        textarea{
            margin-top: 5%;
            margin-bottom: 5%;
        }
        #submit{
            /* margin-top: 15%; */
                width: auto;
            padding: 0px 15px 0px 15px;
            background-color: #EC6C62;
            height: 30px;
            display: inline-block;
            line-height: 25px;
            color: white;
            /* position: relative; */
            border: none;
            border-radius: 17px;
            margin-left: 20px;
            font-size: 14px;
            border: none;
            outline: none;
        }
        .float_left{
            float: left;
        }
        .clear{
            clear: both;
        }
    </style>
    <input type="hidden" name='url' value="<?php echo base_url()?>">
    <input type="hidden" name='sub_role' value="">
    <div class="search-head header mui-bar mui-bar-nav row" style="background-color: #f7f9fa; border:none;">
        <div class="col-xs-1" style="margin-top: 3%">
            <a class=" Hui-iconfont Hui-iconfont-slider-left" href="javascript:void(0)" onclick="history.back();" style="color: #C9C9C9"></a>
        </div>
        <div class="col-xs-11">
            <h1 class="mui-title" style="color:#333;margin-left: -5%">已保存的听课表</h1>
        </div>
    </div>

    <div style="margin-top: 15%;text-align: left;right">
   
        <ul class="list-group">
          
            <?php 
            if($detail==''||$detail==null){echo "还未保存过听课评价表！";exit;}
            echo '<li class="list-group-item">
             <input type="checkbox" id="allCheckbox" onchange="allCheckbox()" style="width:20px;height:20px;">
             <input type="button" id="submit" class="btn lastbtn btn-primary " value="批量提交" onclick="moreSubmit()" ></input>
          </li>';
            foreach ($detail as $k => $v) {
                if($v['back_time']){
                    $color='style="color:red"';
                }else{
                    $color='';
                }
                if($v['is_finish'] == 0){
                   $remark ='<div style="margin-left: 10%">(未填写完整)</div>';
                }else{
                   $remark ='';
                }

                echo "<li class='list-group-item' attend_id='".$v['id']."' $color><input type='checkbox' name='attend_id' value='".$v['id']."' style='width:20px;height:20px;'><div><div class='col-xs-10'  onclick='editAssess(this)' attend_id='".$v['id']."'>".$v['listen_class']."</div><div class='col-xs-2' style='text-align:right'><i class='icon-remove' onclick='del(this)' attend_id='".$v['id']."'></i></div><div class='clear'></div><div  onclick='editAssess(this)' attend_id='".$v['id']."'>".$v['class_name']."-".$v['teacher_name']."-".$v['type_char'].$remark."<div></div></li>";
            }
        ?>
        </ul>

    </div>

    <script>
        function editAssess(t){
            var attend_id=$(t).attr('attend_id');
            var listen_id=$(t).attr('listen_id');
            var class_id=$(t).find('.class_id').val();
            window.location.href=$("input[name='url']").val()+'Home/Class_Assess/Index/'+attend_id;
        }
        function del(t){
            var attend_id=$(t).attr('attend_id');
               dialog1 = jqueryAlert({
                   'style': 'wap',
                   'title': '删除',
                   'content': '请确认是否删除!',
                   'modal': true,
                   'contentTextAlign': 'left',
                   'width': '300',
                   'height': '150',
                   'animateType': 'linear',
                   'buttons': {
                    '否':function(){
                        dialog1.close();
                    },
                       '是': function() {
                           dialog1.close();
                           $.ajax({
                               url: $("input[name='url']").val()+'Home/Class_Assess/delAssess',
                               type: 'POST',
                               dataType: 'json',
                               data: {attend_id: attend_id},
                               success:function(data){
                                   if(data.status){
                                       var dialog1 = jqueryAlert({
                                           'icon': $('input[name="url"]').val() + 'public/home/alert/img/right.png',
                                           'content': data.msg,
                                           'closeTime': 3000,
                                       })
                                       setTimeout("location.reload()",2000);
                                   }else{
                                        var dialog1 = jqueryAlert({
                                           'icon': $('input[name="url"]').val() + 'public/home/alert/img/error.png',
                                           'content': data.msg,
                                           'closeTime': 3000,
                                       })
                                   }
                               }
                           })
                       }
                       

                }
            })
           
            
        }

        //全选
        function allCheckbox(){
          if($("#allCheckbox").is(':checked') == true){//全选
           opcheckboxed('attend_id', 'checkall');
          }else{//取消全选
           opcheckboxed('attend_id', 'uncheckall')
          }
          

        }


        //批量提交听课数据
        function moreSubmit(){
          var id=$("input[type='checkbox']:checked");
         
          if(id.length == 0){
            var dialog1 = jqueryAlert({
                   'icon': $('input[name="url"]').val() + 'public/home/alert/img/error.png',
                   'content': '请选择要提交的听课',
                   'closeTime': 3000,
               })
          }else {
            var chk_value = [];
             $('input[name="attend_id"]:checked').each(function(i){

                chk_value[i] =parseInt($(this).val());
            });
             // console.log(chk_value);return;
                 dialog1 = jqueryAlert({
                           'style': 'wap',
                           'title': '提交',
                           'content': '提交后无法修改,是否确认提交?',
                           'modal': true,
                           'contentTextAlign': 'left',
                           'width': '300',
                           'height': '150',
                           'animateType': 'linear',
                           'buttons': {
                               '否':function(){
                                dialog1.close();
                              },
                               '是': function() {
                                   dialog1.close();
                                   console.log(id);
                                   $.ajax({
                                       url: $("input[name='url']").val()+'Home/Class_Assess/moreSubmit',
                                       type: 'POST',
                                       dataType: 'json',
                                       data: {id: chk_value},
                                       success:function(data){
                                           if(data.status){
                                               var dialog1 = jqueryAlert({
                                                   'icon': $('input[name="url"]').val() + 'public/home/alert/img/right.png',
                                                   'content': data.msg,
                                                   'closeTime': 3000,
                                               })
                                               setTimeout("location.reload()",2000);
                                           }else{
                                                var dialog1 = jqueryAlert({
                                                   'icon': $('input[name="url"]').val() + 'public/home/alert/img/error.png',
                                                   'content': data.msg,
                                                   'closeTime': 3000,
                                               })
                                           }
                                       }
                                   })
                               }
                        }
                    })
               }
        }

        function opcheckboxed(objName, type){
          var objNameList=document.getElementsByName(objName);
          if(null!=objNameList){
            for(var i=0;i<objNameList.length;i++){  
              if(objNameList[i].checked==true)
              {
                if(type != 'checkall') {  // 非全选
                  objNameList[i].checked=false;
                }
                
              } else {
                if(type != 'uncheckall') {  // 非取消全选
                  objNameList[i].checked=true;
                }
              }
            }  
          }
        }

    </script>
</body>
</html>
